package com.zb.service.impl;

import com.zb.dao.TGoodsDetailMapper;
import com.zb.dao.TGoodsMapper;
import com.zb.model.TGoods;
import com.zb.model.TGoodsDetail;
import com.zb.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService{

	@Autowired
	private TGoodsMapper tgm;
	
	@Autowired
	private TGoodsDetailMapper tgd;
	
	public TGoods selectGoodsByIdService(String goodsId) {
		return tgm.selectGoodsMsgById(goodsId);
	}

	public List<TGoods> selectGoodsByCateService(String cateid) {
		return tgm.selectGoodsMsgByCate(cateid);
	}
	
	public TGoodsDetail selectGoodsDetailByIdService(String goodsId) {
		List<TGoodsDetail> goodsDetailList = tgd.selectGoodsDetailById(goodsId);
		if(goodsDetailList!=null)
			return goodsDetailList.get(0);
		else
			return null;
	}
	
	public List<TGoods> selectGoodsService(){
		
		return tgm.selectGoodsMsg();
	}
}
